package com.ldzhao.blog.admin.controller;

import com.ldzhao.blog.service.RemoverService;
import com.ldzhao.blog.spider.model.BaseModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@RestController
@RequestMapping("/admin/remover")
public class RestRemoverController {

    @Autowired
    private RemoverService removerService;

    @PostMapping("/run")
    @ResponseBody
    public void run(Long typeId, BaseModel model, HttpServletResponse response) throws IOException, InterruptedException {
        removerService.run(typeId, model, response.getWriter());
    }

}
